package com.itheima.d07_calendar;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Test {
    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();

        Date time = calendar.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sdf.format(time);



        System.out.println("当前时间"+time);
        System.out.println("年"+calendar.get(Calendar.YEAR));
        System.out.println("月"+calendar.get(Calendar.MONTH));
        System.out.println("时"+calendar.get(Calendar.HOUR));
        System.out.println("分"+calendar.get(Calendar.MINUTE));
        System.out.println("秒"+calendar.get(Calendar.SECOND));


//        calendar.set(2020, 11, 11);
//        System.out.println(calendar.getTime());
        calendar.add(Calendar.MONTH, 3);
        System.out.println(new  SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()));


    }
}
